package com.xn.app.muying.adpter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.xn.app.muying.R;
import com.xn.app.muying.bean.MineYiYuanBean;

import java.util.ArrayList;

/**
 * Created by Administrator on 2016/10/19.
 */
public class MineYiYuanAdapter extends BaseAdapter {
    private final LayoutInflater inflater;
    private Context context;
    private ArrayList<MineYiYuanBean> list = new ArrayList<>();
    private ViewHolder holder = null;

    public MineYiYuanAdapter(Context context) {
        super();
        this.context = context;
        inflater = LayoutInflater.from(context);
    }

    public void getData(ArrayList<MineYiYuanBean> data) {
        this.list=data;
        notifyDataSetChanged();
    }

    @Override
    public int getCount() {

        return list.size();
    }

    @Override
    public Object getItem(int i) {
        return list.get(i);
    }

    @Override
    public long getItemId(int i) {
        return i;
    }

    @Override
    public View getView(int i, View view, ViewGroup viewGroup) {

        if (view == null) {
            view = inflater.inflate(R.layout.mine_yiyuan_listview, null);
            holder = new ViewHolder();
            holder.tv = (TextView) view.findViewById(R.id.mine_yiyuan_tv);
            holder.address= (TextView) view.findViewById(R.id.address);
            view.setTag(holder);
        } else {
            holder = (ViewHolder) view.getTag();
        }
        MineYiYuanBean bean = list.get(i);
        holder.tv.setText(bean.getName());
        holder.address.setText("地址："+bean.getAddress());
        return view;

    }

    class ViewHolder {
        TextView tv;
        TextView address;
    }
}

